<template>

  <div>
    <card-component :content-title="contentTitle">
      <div slot="action">
        <div class="action-wrapper">
          <el-form ref="form" :model="form" label-width="80px" inline>
            <el-form-item label="PCBA编号">
              <el-input v-model="form.pcbaCode" placeholder="请输入PCBA编号" autofocus clearable @change="handlePcbaCodeInput" style="width: 220px;"></el-input>
            </el-form-item>

          </el-form>
          <el-form ref="form" :model="form" label-width="80px" inline>
            <el-form-item :label="$getTextByLangKey('产线')">
              <el-select v-model="form.lineName" placeholder="请选择" style="width: 220px;" @change="handlelineNameChange" clearable>
                <el-option
                  v-for="item in lineList"
                  :key="item.id"
                  :label="item.lineName"
                  :value="item.lineName"
                >
                </el-option>
              </el-select>
            </el-form-item>
            <el-form-item>
              <el-button @click="handleConfirm" type="primary">确认</el-button>
            </el-form-item>
          </el-form>
          <el-form ref="form" :model="form" label-width="80px" inline>
<!--            <el-form-item label="AB面">-->
<!--              <el-input v-model="form.surface" placeholder="请输入AB面" @change="handleSurfaceInput" style="width: 220px;"></el-input>-->
<!--            </el-form-item>-->


          </el-form>
        </div>

      </div>
    </card-component>

    <el-dialog>

    </el-dialog>
  </div>



</template>

<script>

  import card from '@/base/card.vue'
  import checkInput from '@/base/checkInput.vue'
  import request from '@/common/js/request'
  export default {
    components: {
      'card-component': card,
      checkInput,
    },
    data() {
      return {
        contentTitle:'PCBA编码',
        form:{
          pcbaCode:'',
          // surface:localStorage.getItem('surface')||'',
          lineName:localStorage.getItem('lineName')||'',
        },
        id:'',
        lineList:[]
      }
    },
    computed:{

    },
    created: function () {
      request.requestLineList(res=>{
        this.lineList = res.data.data
      })
    },
    watch: {

    },
    methods:{
      handlePcbaCodeInput(v){
        this.form.pcbaCode = v
        this.handleConfirm()
      },
      handleSurfaceInput(v){
        localStorage.setItem('surface',v)
      },
      handlelineNameChange(v){
        localStorage.setItem('lineName',v)
      },

      handleConfirm(){
        if(!this.form.pcbaCode){
          this.$message.error('请输入PCBA编号')
          return
        }
        if(!this.form.lineName){
          this.$message.error('请选择产线')
          return
        }
        // if(!this.form.surface){
        //   this.$message.error('请输入AB面')
        //   return
        // }

        request.requestPcbaRecordUpload({
         ...this.form
        },res=>{
          if(res.data.code === 200){
            this.$message.success('操作成功')
            this.form.pcbaCode = ''
          }else{
            this.$message.error(res.message||'操作失败')
          }
        })
      }
    },

  }
</script>


<style scoped>
  .action-wrapper{
    margin-top: 20px;
    padding-left: 20px;
  }

  .checkInput-wrapper{
    display: flex;
    flex-direction: row;
    padding-left: 40px;
    padding-top: 20px;
  }
  .btn-wrapper{
    display: flex;
    padding: 30px 0;
    width: 600px;
    justify-content: center;
  }

  .item-wrap{
    padding: 5px 0;
    display: flex;
    margin-right: 10px;
  }
  .item-wrap .inner-item{
    width: 320px;
  }
</style>


